package cn.edu.scau.sec.rw.model.pro_manage.threadExe;

import cn.edu.scau.sec.rw.model.pro_manage.Process;
import cn.edu.scau.sec.rw.model.pro_manage.simulation.CPU;

/**
 *CPU执行进程：优先执行就绪队列的进程，无就绪进程时，执行空闲队列
 */
public class CPUThread extends Thread {
    private static  CPU cpu = CPU.getCpu();


    @Override
    public void run() {
        while (true) {
            if (Process.getReadyProcesses().size() != 0) {
                cpu.execute();
            } else {
                cpu.executeFree();
            }
        }
    }
}
